<?php
namespace Home\Controller;
class UsercenterController extends IsloginController{
	function index(){
		$Ob = M("Owner");
		$id=$_SESSION["id"];
		$arr = $Ob->where("id=$id")->find();
		$this->assign("arr",$arr);
		$this->getip();
		$this->display();
	}
    function changemsg(){
    	$Ob = M("Owner");
    	$id = $_GET["id"];
    	$arr1 = $Ob->where("id=$id")->find();
    	$this->assign('arr1',$arr1);
    	$this->getip();
    	$this->display();
    }
    function xiugai(){
    	$Ob = M("Owner");
    	$re = $Ob->data($_POST)->save();
    	if($re){
    		 echo json_encode(array('msg'=>1));
    	}else{
    		 echo json_encode(array('msg'=>0));
    	}
    }
    function fatie(){
	    $this->index();

    }
    function tiwen(){
        $Ob1 = M("Owner");
        $id=$_SESSION["id"];
        $arr2 = $Ob1->where("id=$id")->find();
        $this->assign("arr2",$arr2);
        $Ob = M("Question");
        $uid=$_GET["uid"];
        $arr3 = $Ob->where("uid=$uid")->select();
        $this->assign('arr3',$arr3);
        $this->getip();
    	$this->display();
    }
    function huida(){
        $Ob1 = M("Owner");
        $id=$_SESSION["id"];
        $arr4 = $Ob1->where("id=$id")->find();
        $this->assign("arr4",$arr4);
        $Ob = M("Answer");
        $uid=$_GET["uid"];
        $arr5 = $Ob->where("uid=$uid")->select();
        $this->assign('arr5',$arr5);
        $this->getip();
        $this->display();
    }
    function repassword(){
	    $this->index();
        $this->display();
    }
    function xiugaipassword(){
	    $this->index();
        $verify=new \Think\Verify();
        $verifyRe=$verify->check($_POST['check_code']);
        if($verifyRe){
            $Ob = M("Owner");
            $_POST["password"] = md5($_POST["password"]);
            unset($_POST["oldpassword"]);
            unset($_POST["repassword"]);
            unset($_POST["check_code"]);
            $re = $Ob->data($_POST)->save();
            if($re){
                echo "<script>alert('修改成功');parent.location.href='index';</script>";
            }else{
                echo "<script>alert('修改失败');parent.location.href='repassword';</script>";
            }
        }
        $this->getip();
    }
    public function verifyAction() {
        $config = array(
            'fontSize'    =>    30,    // 验证码字体大小
            'length'      =>    4,     // 验证码位数
            'useNoise'    =>    false, // 关闭验证码杂点
        );
        $Verify = new \Think\Verify($config);
        $Verify->entry();
    }

}